<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">

<head th:replace="fregments :: head(~{::title})">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>挚夕导航</title>
    <!-- Bootstrap -->
    <link rel="stylesheet" href="../static/lib/bootstrap-3.4.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="../static/css/my.css">
    <!-- 动画 -->
    <link rel="stylesheet" href="../static/css/animate.css">
</head>

<body>
<nav th:replace="fregments :: menu(1)" class="navbar navbar-default navbar-fixed-top m-padding">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">
                <img alt="Brand" src="../static/favicon.ico" style="width: 24px;">
            </a>
            <p class="navbar-text navbar-default"><a href="#" class="navbar-link m-a-none"><b>挚夕导航</b></a></p>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#"><span class="glyphicon glyphicon-home">&nbsp;</span>首页</a></li>
                <li><a href="#"><span class="glyphicon glyphicon-pencil">&nbsp;</span>学习</a></li>
                <li role="presentation" class="disabled"><a href="#"><span
                        class="glyphicon glyphicon-bookmark">&nbsp;</span>个人书签</a></li>
            </ul>

            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">
                        <img class="m-avatar img-circle" src="../static/images/me.jpg">
                        挚夕
                        <span class="caret"></span>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-left">
                        <li><a href="#"><span class="glyphicon glyphicon-th">&nbsp;</span>个人主页</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#"><span class="glyphicon glyphicon-log-out">&nbsp;</span>登出</a></li>
                    </ul>
                </li>
            </ul>

            <form class="navbar-form navbar-right">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="搜索" style="width: 300px;">
                </div>
                <button type="submit" class="btn btn-default">
                    <a class="glyphicon glyphicon-search m-none"></a>
                </button>
            </form>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>

<th:block th:replace="fregments :: modal"></th:block>

<div id="way-point" class="animated fadeIn">
    <div class="m-container" id="myContainer">
        <!-- 内容开始 -->
        <div th:fragment="content">
            <!-- 一级导航菜单-->
            <div class="panel panel-default">
                <div class="panel-body">
                    <ul class="nav nav-tabs " id="firstNavContainer">
                        <li class="col-xs-6 col-sm-4 col-md-2"
                            th:if="${firstNavigation != null && firstNavigation.size() > 0}"
                            th:each="firstNav, it : ${firstNavigation}" role="presentation"
                            th:classappend="${firstNav.id == firstNavId} ? 'active'">
                            <a th:data-id="${firstNav.id}" class="firstNavItem">
                                <span th:class="${firstNav.iconClass}"></span>[[${firstNav.name}]]
                                <span class="badge" th:text="${firstNav.linkCnt}">42</span>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

            <!-- 面板开始 -->
            <div class="panel panel-default">
                <div class="panel-heading" id="secondNavContainer">
                    <!-- 二级导航菜单-->
                    <ul class="nav nav-pills" th:if="${secondNavigation != null && secondNavigation.size() > 0}">
                        <li th:each="secondNav,it:${secondNavigation}" role="presentation"
                            th:classappend="${secondNav.id == secondNavId}? 'active'">
                            <a th:data-id="${secondNav.id}" class="secondNavItem" th:text="${secondNav.name}">短视频</a>
                        </li>
                    </ul>
                </div>
                <div class="panel-body">
                    <!-- 链接列表-->
                    <!-- row start -->
                    <div class="row">
                        <div class="col-xs-12 col-sm-6 col-md-3" th:each="link : ${links}">
                            <div class="m-card row animated lightSpeedIn">
                                <a class="m-padded-left-sm m-padded-none col-xs-11 col-sm-11 col-md-11 m-a-none"
                                   th:href="@{/link/{id}(id=${link.id})}">
                                    <!--                                    <div class="m-inline">-->
                                    <div class="m-margin-top-sm m-padded-none col-xs-2 col-sm-2 col-md-2">
                                        <img class="m-png img-circle"
                                             th:src="${link.icon}">
                                    </div>
                                    <div class="m-padded-none m-padded-top-sm col-xs-10 col-sm-10 col-md-10">
                                        <div>
                                            <strong th:text="${link.title}">哔哩哔哩</strong>
                                        </div>
                                        <!--                                            #strings.substring(link.brief, 0, #strings.length(link.brief) > 8 ? 8 : #strings.length(link.brief)) + '...'-->
                                        <div class="text-muted m-brief-control m-inline" th:text="${link.brief}">
                                            哔哩哔哩干杯
                                        </div>
                                    </div>
                                    <!--                                    </div>-->
                                </a>
                                <a class="m-margin-top-big m-padded-none col-xs-1 col-sm-1 col-md-1 m-a-none"
                                   th:href="${link.url}" target="_blank"
                                   data-toggle="tooltip" data-placement="right" data-container="body" title="直达">
                                    <span class="glyphicon glyphicon-chevron-right">&nbsp;</span>
                                </a>
                            </div>
                        </div>
                    </div> <!-- row end -->
                </div><!-- 面板结束 -->
            </div><!-- 内容结束 -->
        </div>
    </div>
</div>

<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<footer th:replace="fregments :: footer">
    <div>
        <div class="row">
            <div class="col-xs-12 col-sm-6 col-md-3">
                <h3>挚夕导航</h3>
                <p>
                    挚夕导航最初源于本人想要做一个管理书签的系统。
                    后来借鉴了一些导航网站，决定做一个网站导航。<br>
                </p>
            </div>
            <div class="col-xs-12 col-sm-6 col-md-9">
                <div class="col-xs-4 col-sm-4 col-md-4" style="margin-top: 20px; margin-bottom: 20px">
                    <img class="m-footer-wechat img-thumbnail" src="../static/images/wechat.jpg" th:src="@{/images/wechat.jpg}">
                </div>
                <div class="col-xs-4 col-sm-4 col-md-4" style="margin-top: 20px; margin-bottom: 20px">
                    <h4>热门链接</h4>

                </div>
                <div class="col-xs-4 col-sm-4 col-md-4" style="margin-top: 20px; margin-bottom: 20px">
                    <h4>热门标签</h4>

                </div>
            </div>
            <div class="col-xs-12 col-sm-12 col-md-12" style="text-align: center;">
                Copyright 2023-now 挚夕导航 Designed by 挚夕
            </div>
        </div>
    </div>
</footer>

<!--/*/<th:block th:replace="fregments::script">/*/-->
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="../static/lib/jquery-1.12.4/jquery.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="../static/lib/bootstrap-3.4.1/js/bootstrap.min.js"></script>
<!--  bootstrap-dropdown-hover -->
<script src="../static/lib/bootstrap-dropdown-hover.js"></script>

<script>
    $(function () {
        //bootstrap-dropdown-hover
        $('.navbar [data-toggle="dropdown"]').bootstrapDropdownHover({
            // see next for specifications
        });
        setTimeout(() => {
            $(".m-card").removeClass("lightSpeedIn");
        }, 3000);

        // // 下拉框鼠标事件
        // $(".dropdown").hover(function () {
        //     $(this).toggleClass("open");
        // });
        //特效
        $("li").hover(function () {
            $(this).toggleClass("m-up");
        })

        // // 卡片特效
        $(".m-card").hover(function () {
            $(this).toggleClass("m-grow")
        })

        $(".m-card").click(function () {
            $(this).toggleClass("tada")
        })
    });
</script>
<!--/*/</th:block>/*/-->

<script>
    <!-- 解决快速点击切换菜单，动画立即结束问题-->
    var cnt = 0;
    function reloadScript() {
        cnt++;
        setTimeout(() => {
            cnt--;
            if (cnt <= 0)
                $(".m-card").removeClass("lightSpeedIn");
        }, 2000);
    }

    //局部加载页面
    function load(secondNavId) {
        $("#myContainer").load(/*[[@{/nav}]]*/"/nav", {
            firstNavId: $("#firstNavContainer li.active a").data('id'),
            secondNavId: secondNavId
        });
        reloadScript();
    }

    $(function () {
        // 卡片特效
        $("#myContainer").on('mouseenter', '.m-card', function () {
            $(this).toggleClass("m-grow")
        });
        $("#myContainer").on('mouseleave', '.m-card', function () {
            $(this).toggleClass("m-grow")
        });

        //一级菜单点击事件
        $("#myContainer").on("click", '.firstNavItem', function () {
            //激活状态，点击无效
            if ($(this).parent().hasClass("active")) return;
            let firstNavId = $(this).data('id');
            $("#myContainer").load(/*[[@{/nav}]]*/"/nav", {
                firstNavId: firstNavId
            });
            reloadScript();
        })
        //二级菜单点击事件
        $("#myContainer").on('click', ".secondNavItem", function () {
            //激活状态，点击无效
            if ($(this).parent().hasClass("active")) return;
            load($(this).data('id'));
        });
    });
</script>
</body>

</html>